package cn.tedu.crm.operatelog.controller;

import cn.tedu.crm.base.pojo.PageObject;
import cn.tedu.crm.base.response.JsonResult;
import cn.tedu.crm.operatelog.pojo.dto.OperateLogQuery;
import cn.tedu.crm.operatelog.pojo.vo.OperateLogVO;
import cn.tedu.crm.operatelog.service.OperateLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "操作日志模块")
@RequestMapping("/api/crm/operateLog/")
public class OperateLogController {
    @Autowired
    OperateLogService operateLogService;
    @ApiOperation("查询操作日志列表")
    @GetMapping("select")
    public JsonResult selectOperateLog(OperateLogQuery query){
        log.debug("查询操作日志列表:入参{}",query);
        PageObject<OperateLogVO> pageObject = PageObject.page(
                query.getPageNum(), query.getPageSize(), () -> operateLogService.loadOperateLog(query));
        return JsonResult.ok(pageObject);
    }
    @ApiOperation("删除操作日志")
    @GetMapping("delete")
    public JsonResult deleteOperateLog(@RequestParam List<Long> ids){
        log.debug("删除操作日志:入参{}",ids);
        operateLogService.deleteOperateLog(ids);
        return JsonResult.ok();
    }
}
